Skip to content

Add local state write shadow validation#872

Merged
huangruiteng merged 1 commit into
mainfrom
codex/local-state-write-shadow-validation-20260628
Jun 30, 2026
Merged

Add local state write shadow validation#872
huangruiteng merged 1 commit into
mainfrom
codex/local-state-write-shadow-validation-20260628

Conversation

@huangruiteng

Copy link
Copy Markdown
Owner

Summary

  • add preview-only shadow validation for local state write correctness packets
  • detect stale active-state revisions and competing todo lease holders without mutating state
  • cover clean, revision_conflict, and lease_conflict cases in the todo write correctness smoke

Validation

  • python3 examples/todo-write-correctness-smoke.py
  • python3 examples/local-state-write-correctness-contract-smoke.py
  • python3 examples/refresh-state-write-correctness-smoke.py
  • python3 -m py_compile loopx/local_state_write_correctness.py examples/todo-write-correctness-smoke.py
  • git diff --check

Boundary

  • public/private scan only matched existing public-boundary field names and imports; no private paths, raw logs, trajectories, or secrets were added

Review note: this is intentionally a dry-run/shadow fixture only. It does not enforce writes or change runtime mutation behavior.

@huangruiteng
huangruiteng force-pushed the codex/local-state-write-shadow-validation-20260628 branch from 05db6a3 to 4925fb3 Compare June 30, 2026 18:59
@huangruiteng

Copy link
Copy Markdown
Owner Author

Self-review result: no blocking findings.

Open questions / assumptions:

  • Assumes this remains a shadow validator for dry-run correctness packets only, not an actual local-state write/apply implementation.
  • Assumes lease conflicts should be reported for same goal/todo lease refs with different holders; same-holder lease-id differences remain non-conflicting in this preview layer.

Product / architecture judgment:

  • Motivation: local active-state writes need a public-safe preview surface that can detect stale revisions and lease ownership conflicts before any mutation path is touched.
  • Solved: the PR adds shadow_validate_local_state_write_correctness_packet, which deep-copies a dry-run packet, computes current active-state revision, reports revision_conflict / lease_conflict, and leaves actual state writes unchanged. The smoke proves clean preview, revision conflict, lease conflict, idempotency stability, markdown projection, and that real todo writes do not expose the dry-run packet.
  • User/operator impact: agents get a safer reviewable preflight for todo/local-state writes, reducing silent overwrite and stale-lease risk without adding production write behavior.
  • Main risk: this is a preview validator, so callers must still wire it intentionally before relying on it. It does not replace file locks or actual write transaction checks.
  • Design judgment: this is a reusable contract slice. During review I refined it by adding todo-write-correctness-smoke.py to the state-write-correctness catalog profile and asserting that wiring in the planner smoke, so the new shadow behavior is covered by the standard non-benchmark canary route.

Validation performed:

  • python3 -m py_compile loopx/local_state_write_correctness.py loopx/canary/planner.py examples/todo-write-correctness-smoke.py examples/catalog-canary-planner-smoke.py examples/catalog-canary-run-e2e-smoke.py
  • python3 examples/todo-write-correctness-smoke.py
  • python3 examples/catalog-canary-planner-smoke.py
  • python3 examples/catalog-canary-run-e2e-smoke.py
  • python3 -m loopx.cli canary run --format json --profile state-write-correctness --max-checks-per-profile 3 --check-limit 3 --timeout-seconds 120 passed 3/3 and included todo-write-correctness-smoke.py.
  • python3 -m loopx.cli canary coverage-audit --format json reported 28/28 covered, drift_count=0.
  • python3 -m loopx.cli check --scan-path loopx/local_state_write_correctness.py --scan-path examples/todo-write-correctness-smoke.py --scan-path loopx/canary/planner.py --scan-path examples/catalog-canary-planner-smoke.py --limit 200 passed public/private boundary scan with one pre-existing duplicate-index warning.
  • git diff --check origin/main...HEAD

Merge decision: approved for owner-authorized self-merge.

@huangruiteng
huangruiteng merged commit 3bed520 into main Jun 30, 2026
@huangruiteng
huangruiteng deleted the codex/local-state-write-shadow-validation-20260628 branch June 30, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant